// const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const CompressionPlugin = require('compression-webpack-plugin')

module.exports = {
  productionSourceMap: false,
  // 分包
  configureWebpack: config => {
    config.optimization = {
      splitChunks: {
        chunks: 'all',
        cacheGroups: {
          'echarts': {
            name: 'echarts',
            test: /[\\/]node_modules[\\/]echarts[\\/]/,
            priority: -10
          },
          'lodash': {
            name: 'lodash',
            test: /[\\/]node_modules[\\/]lodash[\\/]/,
            priority: -10
          },
          'vendors': {
            name: 'vendors',
            test: /[\\/]node_modules[\\/]/,
            priority: -20
          }
        }
      }
    }
    // if (process.env.NODE_ENV === 'production') {
    //   // 为生产环境修改配置...
    //   config.mode = 'production'
    //   return {
    //     plugins: [new CompressionPlugin({
    //       test: /\.js$|\.html$|\.css/, //匹配文件名
    //       threshold: 10240, //对超过10k的数据进行压缩
    //       deleteOriginalAssets: false //是否删除原文件
    //     })]
    //   }
    // }
  }
}